package com.bestcem.xm.om.dao.mapper;

import com.bestcem.xm.om.controller.param.OrgParam;
import com.bestcem.xm.om.dao.dto.OrgContactDTO;
import com.bestcem.xm.om.entity.readonly.UserOrganization;
import com.bestcem.xm.om.grpc.service.param.PeriodTimeParam;
import org.apache.ibatis.annotations.Mapper;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @author zhangfeng <feng.zhang@idiaoyan.com>
 * @version v1.0
 * @date 2021/10/12 14:11
 */
@Mapper
public interface UserOrganizationMapper {

    /**
     * listByStatusNotPrecreated
     * @return
     */
    List<UserOrganization> listByStatusNotPrecreated();

    /**
     * findMinCreateTime
     * @return
     */
    LocalDateTime findMinCreateTime();

    /**
     * listIdByOrgInfo
     * @param name
     * @param code
     * @return
     */
    List<String> listIdByOrgInfo(String name, String code);

    /**
     * listIdByIndustryIdList
     * @param ids
     * @return
     */
    List<String> listIdByIndustryIdList(List<String> ids);

    /**
     * 只查询id，code,name，free_expiryDT,free_expiryId,formal_expiryDT
     * 简要信息
     *
     * @return 组织的简要信息
     * @author xuan.yang@idiaoyan.com
     * @date 2021/11/29 17:49
     */
    List<UserOrganization> listOrgBriefInfo();

    /**
     * 通知中心编辑短信/邮箱页面--动态条件查询租户联系方式
     *
     * @param sql 需要执行的sql
     * @return
     * @author zq.ding <zq.ding@idiaoyan.com>
     * @date 2021/7/15 16:01
     */
    List<OrgContactDTO> listByDynamicParam(String sql);

    /**
     * 根据id查询机构信息
     *
     * @param id 机构id
     * @return com.bestcem.xm.om.entity.mongo.readonly.UserOrganization
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2021/12/2 11:41
     */
    UserOrganization findById(String id);

    /**
     * 查询所有
     *
     * @return java.util.List<com.bestcem.xm.om.entity.mongo.readonly.UserOrganization>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2021/12/8 23:07
     */
    List<UserOrganization> listAllContact();

    /**
     * findByIdList
     * @param orgIdList
     * @return
     */
    List<UserOrganization> findByIdList(List<String> orgIdList);

    /**
     * getByOrgCode
     * @param orgCode
     * @return
     */
    UserOrganization getByOrgCode(String orgCode);

    /**
     * 查询所有机构信息
     *
     * @return java.util.List<com.bestcem.xm.om.entity.readonly.UserOrganization>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/3/14 15:51
     */
    List<UserOrganization> listAll();

    /**
     * 根据钱包id列表查询机构信息
     *
     * @param list
     * @return java.util.List<com.bestcem.xm.om.entity.readonly.UserOrganization>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/3/18 15:53
     */
    List<UserOrganization> listByWalletIds(List<String> list);

    /**
     * 根据id列表查询机构信息
     *
     * @param ids
     * @return java.util.List<com.bestcem.xm.om.entity.readonly.UserOrganization>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/3/22 15:56
     */
    List<UserOrganization> listByIds(Collection<String> ids);

    /**
     * getNameByPackId
     * @param packId
     * @return
     */
    String getNameByPackId(String packId);

    /**
     * 根据套餐id列表查询对应的公司代号
     *
     * @param packageIds
     * @return
     */
    Set<String> listCodeByPackageIds(List<String> packageIds);

    /**
     * listCodeByCreateTime
     * @param registerTime
     * @return
     */
    Set<String> listCodeByCreateTime(PeriodTimeParam registerTime);

    /**
     * listAllCode
     * @return
     */
    Set<String> listAllCode();

    /**
     * listOrganzations
     * @param param
     * @return
     */
    List<UserOrganization> listOrganzations(OrgParam param);

    /**
     * countOrganzations
     * @param orgParam
     * @return
     */
    Integer countOrganzations(OrgParam orgParam);

    /**
     * listAllIds
     * @return
     */
    List<String> listAllIds();

    /**
     * 分页查询租户列表
     *
     * @param limit  limit
     * @param offset offset
     * @return 租户列表
     * @author ympan <yuming.pan@idiaoyan.com>
     * @date 11:39 2022/7/25
     */
    List<UserOrganization> listByPaging(Integer limit, Integer offset);

    /**
     * 查询所有租户数量
     *
     * @return 租户数量
     * @author ympan <yuming.pan@idiaoyan.com>
     * @date 11:39 2022/7/25
     */
    Integer count();

    /**
     * 根据更新时间查询
     *
     * @param createTime
     * @return java.util.List<com.bestcem.xm.om.entity.readonly.UserOrganization>
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2022/8/16 14:12
     */
    List<UserOrganization> listByCreateTimeAndSource(LocalDateTime createTime);
}
